<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字符串反转</title>
</head>
<body>
<script>
    /*
     示例:
    输入: "Let's take contest"
    输出: "s'teL ekat tsetnoc"
    * */
    let str = "Let's take contest";
    let newStr = "";
    let splStr = str.split(" ");
    for (let i = 0; i < splStr.length; i++) {
        let str = reversed(splStr[i]);
        if (i === splStr.length - 1) {
            newStr += str;
        } else {
            newStr += str + " ";
        }
    }

    function reversed(str) {
        return str.split("").reverse().join("");
    }

    console.log(newStr)
</script>
</body>
</html>